package tutorial.lite_mod.store_count;

import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import public_util.model.Const4PublicDataBase;
import public_util.model.PublicMiddleTable;
import public_util.model.ReturnData;
import system_api_4_trade.dao.ApiPublicMiddleTableMapper;
import system_api_4_trade.util.sql.SelectTool;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;

/**
 * 这个类用来提供给before和after方法使用,用于MiddleTable的返回
 */
public class TemplateUtilApi {

    private static Logger logger = Logger.getLogger(TemplateUtilApi.class);






    /**
     * 验证链接: duzikai_api_mgr_public_middle_table?invoke_method=public_load_middle_table_list&pre_db_para_middle_table_name=public_middle_table_lite_mod_schedule_system_sub_arrange&pre_db_para_begin_idx=0&pre_db_para_length_4_list=10
     * 工具零件方法
     * 组装方法: 主要是在before活着after方法里面调用
     * 根据这个零件来拼装
     * @return
     */
    public static ReturnData pre_cmd_para_show_append_info(List<PublicMiddleTable> tbList, HttpServletRequest request, SqlSession session, HashMap<String, Object> params2db, ReturnData resultData)
    {
        ApiPublicMiddleTableMapper middleTableMapper = session.getMapper(ApiPublicMiddleTableMapper.class);
        String pre_cmd_para_show_append_info = request.getParameter("pre_cmd_para_show_append_info");
        if ("true".equals(pre_cmd_para_show_append_info))
        {
            for (int i = 0; i < tbList.size(); i++)
            {
                PublicMiddleTable subArrangeData = tbList.get(i);
                String mid_table_remar_006 = subArrangeData.getMid_table_remark_006();//ID
                if (mid_table_remar_006 == null)
                {
                    logger.error("没有设置mid_table_remar_006的信息");
                    continue;
                }
                HashMap<String, Object> search006 = new HashMap<>();
                search006.put(Const4PublicDataBase.PARA_id_public_middle_table+ "_in", mid_table_remar_006);
                search006.put("pre_db_para_order_by_para", "FIELD(id_public_user_info,"+ mid_table_remar_006 +")");
                search006.put("is_online", "0");
                HashMap<String, Object>  realPara = SelectTool.paramap2selectMap(search006, "public_middle_table_lite_mod_schedule_system");
                List<PublicMiddleTable> banciAll = middleTableMapper.tableDataList(realPara);// 周期的配置
                subArrangeData.setSave_data_000(banciAll);
            }

        }
        return null;
    }


}
